package com.neu.wangxiaoyang.servlet;

import com.neu.wangxiaoyang.service.VisitPageService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "VisitQueryServlet", urlPatterns = {"/VisitQueryServlet.do"})
public class VisitQueryServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String pageIndex=request.getParameter("pageIndex");
        VisitPageService ps = new VisitPageService();
        String pageNum=ps.getpageNum(5);
        List<Map<String, Object>> list=ps.findBypage(pageIndex,5);
        HttpSession session=request.getSession();
        session.setAttribute("pageIndex",pageIndex);
        session.setAttribute("pageNum",pageNum);
        session.setAttribute("list",list);
        request.getRequestDispatcher("WEB-INF/Stuboss/stubs_query.jsp").forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
